/*
 * $Id: RequestTypeFileRetentionDAO.java,v 1.3 2009/07/24 18:27:43 oliver Exp $
 *
 * Copyright (C) 2006 General Electric Company. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 *
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */

/**
 * 
 */
package com.ge.healthcare.autosc.common.database.dao;

import com.ge.healthcare.autosc.common.ASCUtil;
import com.ge.healthcare.autosc.common.database.pojo.CfgRequestDefn;
import com.ge.healthcare.autosc.common.database.pojo.CfgRequestType;
import com.ge.healthcare.autosc.common.database.pojo.CfgRqTypeFileRetention;

/**
 * @author 212042764
 * 
 */
public class RequestTypeFileRetentionDAO extends BaseDAO implements
		IRequestTypeFileRetentionDAO {
	/**
	 * Eclipse generated
	 */
	private static final long serialVersionUID = 3483242289880608562L;
	private static IRequestTypeDAO requestTypeDAO = null;
	private static IRequestDefnDAO requestDefnDAO = null;

	/**
	 * Spring likes me
	 */
	public RequestTypeFileRetentionDAO() {
		super(CfgRqTypeFileRetention.TABLE_NAME);
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.IRequestTypeFileRetentionDAO#saveAlways(java.lang.Object)
	 */
	public void saveAlways(Object pojo) {
		super.save(pojo);
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.IRequestTypeFileRetentionDAO#getByRequestTypeName(java.lang.Long)
	 */
	public CfgRqTypeFileRetention getByRequestTypeName(Long requestDefnId) {
		if (ASCUtil.isNullOrEmptyObject(requestDefnId)){
			return null;
		}
		CfgRequestDefn requestDefn = requestDefnDAO
				.getByRequestDefnId(requestDefnId);
		if (ASCUtil.isNullOrEmptyObject(requestDefn)) {
			return null;
		}
		CfgRequestType requestType = requestTypeDAO
				.getRequestTypeByID(requestDefn.getRequestTypeId());
		if (ASCUtil.isNullOrEmptyObject(requestType)) {
			return null;
		}
		return (CfgRqTypeFileRetention) this.findObjectByID(
				CfgRqTypeFileRetention.COL_REQUEST_TYPE_NAME, requestType
						.getRequestTypeName());
	}

	/**
	 * @param requestTypeDAO
	 *            the requestTypeDAO to set
	 */
	public void setRequestTypeDAO(IRequestTypeDAO requestTypeDAO) {
		RequestTypeFileRetentionDAO.requestTypeDAO = requestTypeDAO;
	}

	/**
	 * @param requestDefnDAO
	 *            the requestDefnDAO to set
	 */
	public void setRequestDefnDAO(IRequestDefnDAO requestDefnDAO) {
		RequestTypeFileRetentionDAO.requestDefnDAO = requestDefnDAO;
	}
}
